-
Notifications
You must be signed in to change notification settings - Fork 70
feat: support durabletask-azurefunctions #309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
| using_legacy = True | ||
| _logger.warning("`azure-functions-durable` is deprecated. " \ | ||
| "Please migrate to the new `durabletask-azurefunctions` package. " \ | ||
| "See <AKA.MS LINK HERE> for more details.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log a warning if azure-functions-durable is being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message is probably too aggressive before we post the Azure deprecation notice, would suggest for now an info message informing about the new package only.
|
|
||
| if using_durable_task and using_legacy: | ||
| # Both packages are installed; prefer `durabletask-azurefunctions`. | ||
| _logger.warning("Both `azure-functions-durable` and " \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case that the customer has both durable packages, log a warning & prioritize durabletask-azurefunctions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There will be more unexpected behavior from the Durable extension if both modules are present, this warning suggests that we will safely default to the new module but that might not always be the case. Recommend changing this message to.
"Both azure-functions-durable and durabletask-azurefunctions packages are installed. This may lead to unexpected behavior, please resolve this conflict by removing one of these packages from the Python environment. Decorators from durabletask-azurefunctions will be used."
| raise Exception(error_message) | ||
| _logger.info("Getting Durable Functions blueprint.") | ||
| df = get_durable_package() | ||
| df_bp = df.Blueprint() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
df here will now be either azure-functions-durable or durabletask-azurefunctions
| class LegacyOrchestrationTriggerConverter(meta.InConverter, | ||
| meta.OutConverter, | ||
| binding='orchestrationTrigger', | ||
| binding=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previous converters are renamed to "Legacy" with no changes. binding is set to None so that they are not automatically registered
|
|
||
| # ---------------- Durable Task Durable Functions Converters ---------------- # | ||
| # Durable Function Orchestration Trigger | ||
| class OrchestrationTriggerConverter(meta.InConverter, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, converters for durable task package are named OrchestrationTrigger Converter, EntityTriggerConverter, ActivityTriggerConverter, and DurableClientConverter - open to renaming if preferable
| def encode(cls, obj: typing.Any, *, | ||
| expected_type: typing.Optional[type]) -> meta.Datum: | ||
| # Durable function context should be a string | ||
| return meta.Datum(type='string', value=obj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New converters for durable task are currently identical to legacy converters except for this change based on microsoft/durabletask-python#75 (comment).
Will update these converters as needed to be compatible with durable task
| _logger.info("Durable Functions package loaded: %s", pkg.__name__) | ||
| _logger.info("Current bindings before registration: %s", meta._ConverterMeta._bindings) | ||
| # Clear existing bindings if they exist | ||
| meta._ConverterMeta._bindings.pop("orchestrationTrigger", None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should never happen, but just in case - if there are bindings already registered for durable, remove them. Then we add the appropriate converter (Legacy vs. new) based on the durable package brought by the customer
| "Attempted to use a Durable Functions decorator, " \ | ||
| "but the `azure-functions-durable` SDK package could not be " \ | ||
| "found. Please install `azure-functions-durable` to use " \ | ||
| "but the `durabletask-azurefunctions` SDK package could not be " \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the case where the customer tries to use a DF decorator (func.FunctionApp) but doesn't have either package installed. df is None, so we raise an error
| # Licensed under the MIT License. | ||
| import logging | ||
|
|
||
| _logger = logging.getLogger('azure.functions.AsgiMiddleware') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of the info logs will be removed in the future, just for debugging purposes now
| _logger.info("`azure-functions-durable` package not found.") | ||
| pass | ||
| try: | ||
| import durabletask.azurefunctions as durable_functions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to check for both? If durabletask is added, lets directly use it and just add a log that durable task is being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need to maintain backwards compatibility with azure-functions-durable. We have to check for both to determine which converter / decorator is being used. This check is only done once though - after that, the df variable will save which module is being used
Adding support for durabletask-azurefunctions.